﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace LiveNation.Utilities {
	public static class HttpResponseBaseExtensions {
		public static string CaptureAction(this HttpResponseBase resp, Action action) {
			resp.Flush();
			var originalFilter = resp.Filter;
			var captureFilter = new CapturingResponseFilter(resp.Filter);
			resp.Filter = captureFilter;
			action();
			resp.Flush();
			var capturedHtml = captureFilter.GetContents(resp.ContentEncoding);
			resp.Filter = originalFilter;

			return capturedHtml;
		}
	}
}
